{% extends "base.html" %}
{% block page_title %}任务详情{% endblock %}

{% block page_css %}
<link href="{{ url_for('static',filename='css/list_detail.css') }}" rel="stylesheet">
{% endblock %}

{% block page_content %}
    <div class="container">
        <h2>{{ task.task_name }}</h2>
        <h5>{{ task.task_description }}</h5>
        <h5>截止时间：{{ task.task_deadline }}</h5>
        <label>任务集列表</label>

        <div class="list-group">
        {% for t in taskList %}
        {% if task.task_name not in t %}
            <li class="list-group-item"><span class="glyphicon glyphicon-folder-open"></span>
            {{ t }}
            {% if current_user.username in t %}
                <a href="{{ url_for('main.deleteFile',id=task.id,filePath=t) }}"><button class="btn btn-info pull-right">删除</button></a>
            {% else %}
                <a href="{{ url_for('main.deleteFile',id=task.id,filePath=t) }}"><button disabled="true" class="btn btn-info pull-right disable">删除</button></a>
            {% endif %}
            </li>

        {% endif %}
        {% endfor %}
        </div>


        {% if current_user.isAdmin() %}
        <button class="btn btn-info pull-right"><a href="{{ url_for('main.downloadTask',id=task.id) }}">下载任务集</a></button>
        {% endif %}

        <!-- 上传任务 -->
        {% if form %}
        <div>
        <form action="/upload" method="post" class="form" enctype="multipart/form-data" role="form">
            {{ form.csrf_token }} 
            <input type="hidden" id="taskId" name="taskId" value="{{ task.id }}">   
            <input id="file" name="file" required type="file" class="input_file">      
            <input class="btn btn-info pull-left" id="submit" name="submit" type="submit" value="上传">
        </form>
        </div>
        {% else %}
        <div>
            <p>　任务已过提交截止日期，无法提交</p>
        </div>
        {% endif %}
    </div>
{% endblock %}